
package ui;

import controllers.ClienteController;
import domain.Cliente;


public class VentanaPrincipalFrm extends javax.swing.JFrame {

    
    CobrosFrm verCobros;
    PlanDeComidasFrm planDeComidas;
    VerClientesFrm verClientes;
    NuevoClienteFrm nuevoCliente;
    
    public VentanaPrincipalFrm() {
        initComponents();
      
        verCobros = new CobrosFrm();
        planDeComidas = new PlanDeComidasFrm();
        verClientes = new VerClientesFrm();
        nuevoCliente = new NuevoClienteFrm();
         
    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        txtDni = new javax.swing.JTextField();
        btnIr = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        btnModificarPlan = new javax.swing.JButton();
        btnNuevoPlan = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        lblNombre = new javax.swing.JLabel();
        lblApellido = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        lblDeuda = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jPCalendar1 = new com.jpcomponents.JPCalendar();
        menuBar = new javax.swing.JMenuBar();
        clientesMenu = new javax.swing.JMenu();
        nuevoClienteMenuItem = new javax.swing.JMenuItem();
        verClientesMenuItem = new javax.swing.JMenuItem();
        preciosMenu = new javax.swing.JMenu();
        verPreciosMenuItem = new javax.swing.JMenuItem();
        cobrosMenu = new javax.swing.JMenu();
        verCobrosMenuItem = new javax.swing.JMenuItem();
        menuMesMenu = new javax.swing.JMenu();
        verMenuMesMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Comedor Universitario - Página principal");
        setMaximumSize(new java.awt.Dimension(735, 357));
        setMinimumSize(new java.awt.Dimension(735, 357));
        setResizable(false);

        jLabel2.setText("DNI:");

        btnIr.setText("Ir");
        btnIr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIrActionPerformed(evt);
            }
        });

        jLabel3.setText("Nombre: ");

        jLabel4.setText("Apellido: ");

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        btnModificarPlan.setText("Modificar plan");
        btnModificarPlan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarPlanActionPerformed(evt);
            }
        });

        btnNuevoPlan.setText("Nuevo plan");
        btnNuevoPlan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoPlanActionPerformed(evt);
            }
        });

        jLabel1.setText("Acciones:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btnNuevoPlan, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(btnModificarPlan))
                        .addContainerGap(41, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(15, 15, 15)
                .addComponent(btnNuevoPlan)
                .addGap(18, 18, 18)
                .addComponent(btnModificarPlan)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        lblNombre.setText("lblNombre");

        lblApellido.setText("lblApellido");

        jLabel5.setText("Deuda total: ");

        lblDeuda.setText("lblDeuda");

        jLabel6.setFont(new java.awt.Font("Perpetua Titling MT", 0, 18)); // NOI18N
        jLabel6.setText("UTN Facultad Regional San Francisco");

        jLabel7.setFont(new java.awt.Font("Perpetua Titling MT", 0, 14)); // NOI18N
        jLabel7.setText("Comedor Universitario");

        jPCalendar1.setMultipleSelectionAlowed(true);

        clientesMenu.setText("Clientes");

        nuevoClienteMenuItem.setText("Nuevo");
        nuevoClienteMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nuevoClienteMenuItemActionPerformed(evt);
            }
        });
        clientesMenu.add(nuevoClienteMenuItem);

        verClientesMenuItem.setText("Ver todos");
        verClientesMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                verClientesMenuItemActionPerformed(evt);
            }
        });
        clientesMenu.add(verClientesMenuItem);

        menuBar.add(clientesMenu);

        preciosMenu.setText("Precios");

        verPreciosMenuItem.setText("Ver");
        preciosMenu.add(verPreciosMenuItem);

        menuBar.add(preciosMenu);

        cobrosMenu.setText("Cobros");

        verCobrosMenuItem.setText("Ver");
        verCobrosMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                verCobrosMenuItemActionPerformed(evt);
            }
        });
        cobrosMenu.add(verCobrosMenuItem);

        menuBar.add(cobrosMenu);

        menuMesMenu.setText("Menú del mes");

        verMenuMesMenuItem.setText("Ver");
        menuMesMenu.add(verMenuMesMenuItem);

        menuBar.add(menuMesMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 170, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addGap(265, 265, 265))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addGap(161, 161, 161))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(45, 45, 45)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(lblApellido))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(lblNombre))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel2)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtDni, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(btnIr, javax.swing.GroupLayout.Alignment.TRAILING)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(lblDeuda)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPCalendar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(43, 43, 43))))
            .addComponent(jSeparator1)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel7)
                .addGap(3, 3, 3)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(9, 9, 9)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel2)
                                    .addComponent(txtDni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnIr)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel3)
                                    .addComponent(lblNombre))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel4)
                                    .addComponent(lblApellido)))
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(26, 26, 26)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(lblDeuda)))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPCalendar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void nuevoClienteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nuevoClienteMenuItemActionPerformed
        nuevoCliente.setVisible(true);
    }//GEN-LAST:event_nuevoClienteMenuItemActionPerformed

    private void verCobrosMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_verCobrosMenuItemActionPerformed
        verCobros.setVisible(true);
    }//GEN-LAST:event_verCobrosMenuItemActionPerformed

    private void btnNuevoPlanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoPlanActionPerformed
      planDeComidas.setVisible(true);
    }//GEN-LAST:event_btnNuevoPlanActionPerformed

    private void verClientesMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_verClientesMenuItemActionPerformed
        verClientes.setVisible(true);
    }//GEN-LAST:event_verClientesMenuItemActionPerformed

    private void btnIrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIrActionPerformed
        //obtener el cliente
        Cliente clienteBuscado=null;
        
        try{
        ClienteController controladorCliente=new ClienteController();
                
        int dniClienteABuscar=Integer.parseInt(txtDni.getText());
        clienteBuscado=controladorCliente.obtenerCliente(dniClienteABuscar);
        
        //mostrar el plan en el calendario o lo que usemos jaja
        //esto lo vamos a dejar porque hay que ver como implementamos el calendario
        
        lblApellido.setText(clienteBuscado.getApellido());
        lblNombre.setText(clienteBuscado.getNombre());
        //lblDeuda.setText();  creo que no hay fiado asi que deuda no creo que haya
        }
        catch(Exception ex)
        {
            //mensajito, no se encuentra o no se puede cargar
        }
        
    }//GEN-LAST:event_btnIrActionPerformed

    private void btnModificarPlanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarPlanActionPerformed
        planDeComidas.setVisible(true);
    }//GEN-LAST:event_btnModificarPlanActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
       
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(VentanaPrincipalFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(VentanaPrincipalFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(VentanaPrincipalFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(VentanaPrincipalFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new VentanaPrincipalFrm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnIr;
    private javax.swing.JButton btnModificarPlan;
    private javax.swing.JButton btnNuevoPlan;
    private javax.swing.JMenu clientesMenu;
    private javax.swing.JMenu cobrosMenu;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private com.jpcomponents.JPCalendar jPCalendar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel lblApellido;
    private javax.swing.JLabel lblDeuda;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenu menuMesMenu;
    private javax.swing.JMenuItem nuevoClienteMenuItem;
    private javax.swing.JMenu preciosMenu;
    private javax.swing.JTextField txtDni;
    private javax.swing.JMenuItem verClientesMenuItem;
    private javax.swing.JMenuItem verCobrosMenuItem;
    private javax.swing.JMenuItem verMenuMesMenuItem;
    private javax.swing.JMenuItem verPreciosMenuItem;
    // End of variables declaration//GEN-END:variables
}
